Skip to content

Fix #5466: preserve text content in mixed-modality Gemini responses#5808

Closed
anuragg-saxenaa wants to merge 2 commits intospring-projects:mainfrom
anuragg-saxenaa:fix/5466-gemini-mixed-modality-streaming
Closed

Fix #5466: preserve text content in mixed-modality Gemini responses#5808
anuragg-saxenaa wants to merge 2 commits intospring-projects:mainfrom
anuragg-saxenaa:fix/5466-gemini-mixed-modality-streaming

Conversation

@anuragg-saxenaa
Copy link
Copy Markdown

Summary

Fixes issue where GoogleGenAiChatModel drops text content when a Gemini response contains both text parts and function call parts (mixed modality).

Problem

The responseCandidateToGeneration method used an if/else branching on isFunctionCall that caused text content to be discarded when function calls were present in the response.

Solution

Combine text content and function calls into a single Generation instead of mutually exclusive branches.

Test

Added GoogleGenAiChatModelMixedContentTests with regression tests for mixed content scenarios.

@anuragg-saxenaa anuragg-saxenaa force-pushed the fix/5466-gemini-mixed-modality-streaming branch from b248861 to 1937685 Compare April 16, 2026 12:41
… both text and function calls

When Gemini returns content with both text parts and function call parts,
the responseCandidateToGeneration method now correctly preserves both instead
of dropping text content when function calls are present.

Signed-off-by: anuragg-saxenaa <anuragg.saxenaa@gmail.com>
@anuragg-saxenaa anuragg-saxenaa force-pushed the fix/5466-gemini-mixed-modality-streaming branch from da98a89 to 873b5bb Compare April 16, 2026 22:20
…nchanged when history is empty

- Added early return in transform() when history is empty to avoid calling the LLM
- Added unit test whenHistoryIsEmptyThenReturnQueryUnchanged()
- This prevents nonsensical transformed queries from duplicate user query in history and follow-up sections

Signed-off-by: anuragg-saxenaa <anuragg.saxenaa@gmail.com>
@anuragg-saxenaa anuragg-saxenaa force-pushed the fix/5466-gemini-mixed-modality-streaming branch from 873b5bb to 4906312 Compare April 17, 2026 12:50
@anuragg-saxenaa
Copy link
Copy Markdown
Author

Closing this PR. Apologies for the noise — going forward all contributions will go through proper human review before submission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant